package main

import (
	"fmt"
)

func ifMatch(str string) int {
	// n := len(str)
	var stack []int = make([]int, 15)
	var top int = -1

	for _, v := range str {
		if v == '(' {
			top++
			stack[top] = int(v)
		} else {
			if top == -1 || stack[top] == ')' {
				// return false
				top++
				stack[top] = int(v)
			} else {
				stack[top] = 0
				top--
			}
		}
		fmt.Println(stack)
	}
	
	if top == -1 {
		return 0
	}
	return top + 1
}

func main() {
	res := ifMatch("()())()()(())(((())())))((())))()()(")
	fmt.Println(res)
}